﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bai2
{
    class Program
    {
        static void Main(string[] args)
        {
            TamGiac[] tamgiac;
            int tong;
            Console.Write("Nhap so tam giac: ");
            tong = Convert.ToInt32(Console.ReadLine());
            tamgiac = new TamGiac[tong];
            Console.WriteLine("NHAP THONG TIN CAC TAM GIAC");
            for (int i = 0; i < tong; i++)
            {
                tamgiac[i] = new TamGiac();
                tamgiac[i].nhap();
            }
            Console.WriteLine("HIEN THI THONG TIN");
            for (int i = 0; i < tong; i++)
            {
                Console.WriteLine("Tam Giac {0}", (i + 1));
                tamgiac[i].dientich();
                Console.WriteLine("==================");
            }
            Console.ReadKey();


        }
    }
    public class HinhHoc
    {
        //du lieu
        private string dangHinhHoc;
        //hanhvi
    }
    public class TamGiac : HinhHoc
    {
        //dulieu
        private float a, b, c;
        //hanhvi
        public TamGiac()
        {
            a = 0;
            b = 0;
            c = 0;
        }
        public TamGiac(float _a, float _b, float _c)
        {
            a = _a;
            b = _b;
            c = _c;
        }
        public void set_a(float _a)
        {
            a = _a;
        }
        public void set_b(float _b)
        {
            b = _b;
        }
        public void set_c(float _c)
        {
            c = _c;
        }
        public float get_a()
        {
            return a;
        }
        public float get_b()
        {
            return b;
        }
        public float get_c()
        {
            return c;
        }
        public int kt()
        {
            int kt;
            if ((a+b<=c)||(a+c<=b)||(b+c<=a)) kt=1; else kt=0;
            return kt;
        }
        public void nhap()
        {
            Console.Write("Nhap a: ");
            set_a(Convert.ToSingle(Console.ReadLine()));
            Console.Write("Nhap b: ");
            set_b(Convert.ToSingle(Console.ReadLine()));
            Console.Write("Nhap c: ");
            set_c(Convert.ToSingle(Console.ReadLine()));
            if (kt() == 1)
            {
                Console.WriteLine("NHAP SAI THONG TIN TAM GIAC!! NHAP LAI!");
                Console.ReadKey();
                nhap();
            }
        }
        public void dientich()
        {
            double dientich, p = a + b + c;
            dientich = Math.Sqrt(p * (p - a) * (p - b) * (p - c));
            Console.WriteLine("Dien tich tam giac: {0:F2}", dientich);
        }
    }
}
